//
//  UIImage+Capture.m
//  AutoLayoutSd_autoLayout
//
//  Created by zhoujian on 16/3/16.
//  Copyright © 2016年 zhoujian. All rights reserved.
//

#import "UIImage+Capture.h"

@implementation UIImage (Capture)

+(instancetype)captureWithImage:(UIView *)view
{
        //开启图片获取上下文
        UIGraphicsBeginImageContextWithOptions(view.frame.size, YES, 0);
        
        //将view的layer图层渲染到上下文(截图)
        [view.layer renderInContext:UIGraphicsGetCurrentContext()];
        
        
        //截图完成以后从图层中取出图片
        UIImage*image=UIGraphicsGetImageFromCurrentImageContext();
        
    
        //结束图片上下文
        UIGraphicsEndImageContext();
    
    return image;
}
@end
